package sz.szsmk.citizencard.ui.newversion.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.annotation.NonNull
import com.google.gson.Gson
import kotlinx.android.synthetic.main.dialog_logout_confirm.*
import sz.szsmk.citizencard.R
import sz.szsmk.citizencard.model.network.bean.response.IUserInfo.UserExBean
import sz.szsmk.citizencard.ui.activity.UserSafeActivity
import sz.szsmk.citizencard.util.ACache
import sz.szsmk.citizencard.util.JumpUtils

/**
 *  author : hyt
 *  date : 2020/8/12
 *  description :
 */
class LogOutDialog(@NonNull context: Context) : Dialog(context,R.style.alertdialog) {

    var iLogOffDialogClick:ILogOffDialogClick ?= null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(LayoutInflater.from(context).inflate(R.layout.dialog_logout_confirm , null))
        val divierId = context.resources.getIdentifier("android:id/titleDivider", null, null)
        val divider = findViewById<View>(divierId)
        divider.visibility = View.GONE
        initView()
    }

    private fun initView(){
        btn_cancel.setOnClickListener { v: View? -> this@LogOutDialog.dismiss() }
        btn_ok.setOnClickListener{
            iLogOffDialogClick?.onClick()
            dismiss()
        }

        val userinfo: String = ACache.get(context).getAsString("userinfo")
        val mUserInfo = Gson().fromJson(userinfo, UserExBean::class.java)
        if (mUserInfo != null) {
            tv_phone.text = "注销账户：${mUserInfo.mobile}"
        }

    }

    public interface ILogOffDialogClick{
        fun onClick()
    }
}